package com.ruoyi.develop.projectOrderInfo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.projectOrderInfo.domain.ProjectOrderInfo;
import com.ruoyi.develop.projectOrderInfo.service.IProjectOrderInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目采购信息管理Controller
 * @author qh
 * @date 2023-01-10
 */
@RestController
@RequestMapping("/projectOrderInfo/projectOrderInfo")
public class ProjectOrderInfoController extends BaseController {
    @Autowired
    private IProjectOrderInfoService projectOrderInfoService;

    /**
     * 查询项目采购信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('develop:ProjectOrderInfo:query')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectOrderInfo entity) {
        startPage();
        List<ProjectOrderInfo> list = projectOrderInfoService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出项目采购信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('develop:ProjectOrderInfo:export')")
    @Log(title = "项目采购信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectOrderInfo entity) {
        List<ProjectOrderInfo> list = projectOrderInfoService.selectList(entity);
        ExcelUtil<ProjectOrderInfo> util = new ExcelUtil<ProjectOrderInfo>(ProjectOrderInfo. class);
        util.exportExcel(response, list, "项目采购信息管理数据");
    }

    /**
     * 获取项目采购信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:ProjectOrderInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(projectOrderInfoService.selectById(id));
    }

    /**
     * 新增项目采购信息管理
     */
    @PreAuthorize("@ss.hasPermi('develop:ProjectOrderInfo:add')")
    @Log(title = "项目采购信息管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ProjectOrderInfo entity) {
        return toAjax(projectOrderInfoService.insert(entity));
    }

    /**
     * 修改项目采购信息管理
     */
    @PreAuthorize("@ss.hasPermi('develop:ProjectOrderInfo:edit')")
    @Log(title = "项目采购信息管理", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ProjectOrderInfo entity) {
        return toAjax(projectOrderInfoService.update(entity));
    }

    /**
     * 删除项目采购信息管理
     */
    @PreAuthorize("@ss.hasPermi('develop:ProjectOrderInfo:remove')")
    @Log(title = "项目采购信息管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(projectOrderInfoService.deleteByIds(ids));
    }
}
